< previous page page_29 next page >

Page 29
12181-0029a.gif
Figure 1.16.
The UpDown control shown in Visual
Basic's toolbox.
To see how this control works, add a Textbox control and an UpDown control to your demo form. Position these controls and label them as shown in Figure 1.17. These two controls will allow users to control a numeric value by using the built-in capabilities of the UpDown control.
12181-0029b.gif
Figure 1.17.
The demo form showing the
UpDown and Textbox
controls added.
Before anything can happen when you click the UpDown buttons, you must set several properties in the control. Select the UpDown control; then right-click it and select Properties from the pop-up menu. Go to the Buddy tabbed page and set the BuddyControl property to the name of the Textbox control you added. Next, set the BuddyProperty property to Default. This will use the default property of the Textbox control, which is Text. Move to the Scrolling page to set the properties that control the behavior of the UpDown control:
Increment, the amount that a value will change with each button click.
Max, the maximum value that can be set.
Min, the minimum value that can be set.
Wrap, which tells the control to wrap from the Max value to the Min value, thus preventing invalid numbers from being selected. This property can be True or False.
Set these properties to 1, 10, and 1, respectively, and click Wrap to turn the feature on. Don't forget to set the initial value of the Textbox to a valid number in the specified Min/Max range. If you forget to do this, an error won't happen; however, the text box will contain whatever the default value was.

 
< previous page page_29 next page >

If you like this book, buy it!